﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PocketPatients
{
    public partial class PatientEditForm : Form
    {
        public static PatientEditForm Instance
        {
            get
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                if ((defaultInstance == null))
                {
                    defaultInstance = new PatientEditForm();
                    defaultInstance.DataBindings.Add("Text", SharedData.Patients, "FullName", false, DataSourceUpdateMode.Never);
                    defaultInstance.textBox1.DataBindings.Add("Text", SharedData.Patients, "LastName", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.textBox2.DataBindings.Add("Text", SharedData.Patients, "FirstName", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.dateTimePicker1.DataBindings.Add("Value", SharedData.Patients, "BirthDay", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.textBox3.DataBindings.Add("Text", SharedData.Patients, "Telephone", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.textBox4.DataBindings.Add("Text", SharedData.Patients, "Mobile", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.textBox5.DataBindings.Add("Text", SharedData.Patients, "WorkPhone", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.textBox6.DataBindings.Add("Text", SharedData.Patients, "Address", false, DataSourceUpdateMode.OnValidation);
                    defaultInstance.pictureButton1.DataBindings.Add("BackgroundImage", SharedData.Patients, "Photograph", false, DataSourceUpdateMode.OnValidation);

                }
                defaultInstance.AutoScrollPosition = new System.Drawing.Point(0, 0);
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                return defaultInstance;
            }
        }
        private static PatientEditForm defaultInstance;

        private PatientEditForm()
        {
            InitializeComponent();
        }

        private void pictureButton1_Click(object sender, EventArgs e)
        {
            OpenFileDialog filedialog = new OpenFileDialog();
            filedialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF";
            if (filedialog.ShowDialog() == DialogResult.OK)
            {
                this.pictureButton1.BackgroundImage = new System.Drawing.Bitmap(filedialog.FileName);
            }
        }
    }
}